import java.util.Stack;

class Solution {
    class MinStack {
        public Stack<Integer> stack;
        public Stack<Integer> minStack;
        public MinStack() {
            stack=new Stack<>();
            minStack=new Stack<>();
        }

        public void push(int val) {
            stack.push(val);
            if(minStack.empty()){
                minStack.push(val);
            }else{
                if(val<=minStack.peek()){
                    minStack.push(val);
                }
            }
        }

        public void pop() {
            if(stack.empty()){
                return;
            }
            int x=stack.pop();
            if(x==minStack.pop()){
                minStack.pop();
            }


        }

        public int top() {
            if(stack.empty()){
                return -1;
            }else{
                return stack.peek();
            }
        }



        public int getMin() {
            if(minStack.empty()){
                return -1;
            }
            return minStack.peek();



        }
    }

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(val);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.getMin();
 */
}